#include <vector>
#include <iostream>
#include <algorithm>
// #include <numeric>
#include <execution>
#include "timer.hpp"
#include <cmath>
int main()
{
    int numElems = 1'000'000;

    struct Data
    {
        double value;
        double sqrt;
    };

    std::vector<Data> coll;
    coll.reserve(numElems);

    for (int i = 0; i < numElems; ++i)
    {
        coll.push_back(Data{i * 4.37, 0});
    }
    Timer timer;
    for_each(std::execution::par,
             coll.begin(), coll.end(),
             [](auto &val)
             {
                 val.sqrt = std::sqrt(val.value);
             });

    timer.printDiff();

    for_each(std::execution::seq,
             coll.begin(), coll.end(),
             [](auto &val)
             {
                 val.sqrt = std::sqrt(val.value);
             });

    timer.printDiff();
}